home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / cstwnd / custwind.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-30  |  9.5 KB  |  283 lines

  1. #ifndef _CUSTWIND_H_
  2. #define _CUSTWIND_H_
  3.  
  4. #ifndef __OWL_H
  5. #include <owl.h>
  6. #endif
  7.  
  8. #ifndef _CUSTSTRC_H_
  9. #include "custstrc.h"
  10. #endif
  11.  
  12. #ifndef _CUSTID_H_
  13. #include "custid.h"
  14. #endif
  15.  
  16. #ifndef _NCBUTTON_H_
  17. #include "ncbutton.h"
  18. #endif
  19.  
  20. #define HTNCBUTTON    50
  21. #define MAX_NCBUTTONS    20
  22.  
  23. #define WM_CUSTOMUPDATEWINDOW    WM_USER + 50
  24.  
  25. #define WTYPE_WINDOW    0
  26. #define WTYPE_DIALOG 1
  27.  
  28. HINSTANCE _EXPORT GetCustWindInstance(void);
  29. PTModule _EXPORT GetCustWindModule(void);
  30.  
  31. _CLASSDEF(TUnderlying)
  32. class _EXPORT TUnderlying
  33. {
  34.     HICON    ClassIcon;
  35.     HCURSOR OldCursor;
  36.  
  37.    char    NoCenter;    //Do not center during setup
  38.  
  39.     PTNCButton    NCButtons[MAX_NCBUTTONS];
  40.     char    ButtonCapt,LastIn;
  41.  
  42.     void HandleButtonMove(RTMessage Msg);
  43. public:
  44.     HWND    MyHWindow;
  45.     PTWindowsObject MyParent;
  46.     PTWindowsObject Me;
  47.     BYTE Type;
  48.     //The following declarations are so that this
  49.     //class can reference these functions that will
  50.     //when derived reference the REAL functions of
  51.    //these.
  52.     void SetThis(PTWindowsObject This)
  53.         {    MyHWindow = This->HWindow;
  54.             MyParent = This->Parent;
  55.             Me = This; };
  56.  
  57.     //Default Constructor, so that only one of the
  58.     //derived classes to have TUnderlying in its
  59.    //initializer list.
  60.    TUnderlying() { };
  61.     TUnderlying(PCustColors Colors);
  62.     TUnderlying(PCustColors, PCustCursors);
  63.     virtual ~TUnderlying();
  64.  
  65.     void SetNoCustom(void)
  66.         {    Chars.CustomLevel = 0;
  67.             InvalidateRect(MyHWindow, NULL, TRUE); };
  68.     void SetLightCustom(void)
  69.         {    Chars.CustomLevel = 1;
  70.             InvalidateRect(MyHWindow, NULL, TRUE);};
  71.     void SetHeavyCustom(void)
  72.         {    Chars.CustomLevel = 2;
  73.             InvalidateRect(MyHWindow, NULL, TRUE); };
  74.     void DontCenter(void)
  75.        {    NoCenter = TRUE; };
  76.  
  77.    void DrawNCButton(int Button);
  78.     //User Definable
  79.     //The three are used to allow shorter functions,
  80.     //thus more readibility, and also to allow derived
  81.    //classes to not have to draw all of the parts
  82.     virtual void UserFrame(HDC DrawDC);
  83.     virtual void UserTitle(HDC DrawDC);
  84.     virtual void DrawSysMenu(HDC DrawDC);
  85.    virtual void DrawMinMax(HDC DrawDC);
  86.  
  87.     virtual void USetupWindow();
  88.     virtual void UCtlColor(RTMessage Msg);
  89.     virtual void UPaint(RTMessage Msg);
  90.     virtual void UNCPaint(RTMessage Msg);
  91.     virtual void UActivate(RTMessage Msg);
  92.     virtual void USetText(RTMessage Msg);
  93.     virtual void UNCActivate(RTMessage Msg);
  94.     virtual void UUpdateEntireWindow(RTMessage)
  95.         { InvalidateRect(MyHWindow, NULL, TRUE); };
  96.     virtual void UClose(RTMessage Msg);
  97.     virtual void USize(RTMessage Msg);
  98.     virtual void UDestroy(RTMessage Msg)
  99.        {  Chars.Closing = TRUE;    };
  100.     virtual void UEraseBkGnd(RTMessage Msg);
  101.     virtual void UNCMouseMove(RTMessage Msg);
  102.     virtual void UMouseMove(RTMessage Msg);
  103.     virtual void USetCursor(RTMessage Msg);
  104.     virtual void UNCLButtonDown(RTMessage Msg);
  105.     virtual void UNCLButtonUp(RTMessage Msg);
  106.     virtual BOOL ULButtonDown(RTMessage Msg);
  107.     virtual void ULButtonUp(RTMessage Msg);
  108.     virtual void UNCHitTest(RTMessage Msg);
  109.  
  110.     BOOL AddNCButton(PTNCButton AButton);
  111.     BOOL RemoveNCButton(PTNCButton AButton);
  112.     BOOL RemoveNCButton(int Id);
  113.     PTNCButton GetNCButton(int Id);
  114.  
  115.     void AddExtendedButtons(HINSTANCE Inst, int StartRight);
  116.    void DeleteExtendedButtons(void);
  117.     //Inline functions of NCButton positioning
  118.     void PosFromTopLeft(RECT& ARect, int APos)
  119.         { AreaFromTopLeft(ARect, APos); };
  120.     void PosFromTopRight(RECT& ARect, int APos)
  121.         { AreaFromTopRight(ARect, APos); };
  122.     //There are times when an inline funciton is required
  123.     //instead of a define
  124.  
  125. protected:
  126.     virtual void CalcRegions(void);
  127.     virtual void Construct(PCustColors Colors, PCustCursors);
  128.     virtual void DrawFrame(void);
  129.  
  130.     //These variables are protected so derived classes
  131.    //have access to them
  132.     HBRUSH    Background;
  133.     struct {
  134.         unsigned int IsActive    : 1;
  135.         unsigned int Closing        : 1;
  136.         unsigned int SysMenu        : 1;
  137.         unsigned int MinBox        : 1;
  138.         unsigned int MaxBox        : 1;
  139.         unsigned int Caption        : 1;
  140.         unsigned int CustomLevel: 2;
  141.         unsigned int IsChild        : 1;
  142.     } Chars;
  143.     RECT    WindowRect, TitleRect, ClientRect;
  144.     POINT    SysMenu, MaxButton, MinButton;
  145.    int    BorderSize, BitWidth, BitHeight, TitleHeight;
  146.     CustColors    DrawColors;
  147.    CustCursors    MouseCursors;
  148.  
  149.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  150.     virtual void ChangeCursor(int HitTest);
  151. };
  152.  
  153. _CLASSDEF(TCustomDialog)
  154. class _EXPORT TCustomDialog : public TDialog,
  155.     virtual public TUnderlying
  156. {
  157. public:
  158.     TCustomDialog(PTWindowsObject AParent, LPSTR AName,
  159.         PCustColors Colors, PTModule AModule = NULL);
  160.     TCustomDialog(PTWindowsObject AParent, int ResourceId,
  161.         PCustColors Colors, PTModule AModule = NULL);
  162.     TCustomDialog(PTWindowsObject AParent, LPSTR AName,
  163.         PCustColors Colors, PCustCursors Cursors,
  164.         PTModule AModule = NULL);
  165.     TCustomDialog(PTWindowsObject AParent, int ResourceId,
  166.         PCustColors Colors, PCustCursors Cursors,
  167.         PTModule AModule = NULL);
  168.  
  169.     virtual void SetupWindow()
  170.         {  SetThis(this);
  171.             USetupWindow();
  172.           TDialog::SetupWindow(); };
  173.     virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR]
  174.        { UCtlColor(Msg); };
  175.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
  176.         {  UPaint(Msg);    };
  177.     virtual void WMNCPaint(RTMessage Msg) = [WM_FIRST + WM_NCPAINT]
  178.        { UNCPaint(Msg);    };
  179.     virtual void WMActivate(RTMessage Msg) = [WM_FIRST + WM_ACTIVATE]
  180.         { UActivate(Msg);
  181.             TDialog::WMActivate(Msg);    };
  182.     virtual void WMSetText(RTMessage Msg) = [WM_FIRST + WM_SETTEXT]
  183.        { USetText(Msg);    };
  184.     virtual void WMNCActivate(RTMessage Msg) = [WM_FIRST + WM_NCACTIVATE]
  185.        { UNCActivate(Msg);    };
  186.     virtual void WMUpdateEntireWindow(RTMessage Msg) = [WM_FIRST + WM_CUSTOMUPDATEWINDOW]
  187.         { UUpdateEntireWindow(Msg); };
  188.     virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE]
  189.         { UClose(Msg);
  190.             TDialog::WMClose(Msg);    };
  191.     virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE]
  192.         {  USize(Msg); };
  193.     virtual void WMDestroy(RTMessage Msg) = [WM_FIRST + WM_DESTROY]
  194.         {    UDestroy(Msg);
  195.             TDialog::WMDestroy(Msg);    };
  196.     virtual void WMEraseBkGnd(RTMessage Msg) = [WM_FIRST + WM_ERASEBKGND]
  197.         {    UEraseBkGnd(Msg);    };
  198.     virtual void WMNCMouseMove(RTMessage Msg) = [WM_FIRST + WM_NCMOUSEMOVE]
  199.        {    UNCMouseMove(Msg);    };
  200.     virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE]
  201.        {    UMouseMove(Msg);    };
  202.     virtual void WMSetCursor(RTMessage Msg) = [WM_FIRST + WM_SETCURSOR]
  203.        {    USetCursor(Msg);    };
  204.     virtual void WMNCLButtonDown(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONDOWN]
  205.         {    UNCLButtonDown(Msg);    };
  206.     virtual void WMNCLButtonUp(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONUP]
  207.        {    UNCLButtonUp(Msg);    };
  208.     virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN]
  209.         {    ULButtonDown(Msg);    };
  210.     virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP]
  211.        {    ULButtonUp(Msg);    };
  212.     virtual void WMNCHitTest(RTMessage Msg) = [WM_FIRST + WM_NCHITTEST]
  213.         {    UNCHitTest(Msg);    };
  214.     virtual void Cancel(RTMessage Msg) = [ID_FIRST + IDCANCEL]
  215.         {  Chars.Closing = 1;
  216.             TDialog::Cancel(Msg); };
  217. protected:
  218.     virtual LPSTR GetClassName();
  219.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  220. };
  221.  
  222. _CLASSDEF(TCustomWindow)
  223. class _EXPORT TCustomWindow : public TWindow,
  224.     virtual public TUnderlying
  225. {
  226. public:
  227.     TCustomWindow(PTWindowsObject AParent, LPSTR ATitle,
  228.         PCustColors Colors, PTModule AModule = NULL);
  229.     TCustomWindow(PTWindowsObject AParent, LPSTR ATitle,
  230.         PCustColors Colors, PCustCursors Cursors,
  231.         PTModule AModule = NULL);
  232.  
  233.     virtual void SetupWindow()
  234.         {  SetThis(this);
  235.             USetupWindow();
  236.           TWindow::SetupWindow(); };
  237.     virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR]
  238.        { UCtlColor(Msg); };
  239.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
  240.         {  TWindow::WMPaint(Msg);
  241.             UPaint(Msg);    };
  242.     virtual void WMNCPaint(RTMessage Msg) = [WM_FIRST + WM_NCPAINT]
  243.        { UNCPaint(Msg);    };
  244.     virtual void WMActivate(RTMessage Msg) = [WM_FIRST + WM_ACTIVATE]
  245.         { UActivate(Msg);
  246.             TWindow::WMActivate(Msg);    };
  247.     virtual void WMSetText(RTMessage Msg) = [WM_FIRST + WM_SETTEXT]
  248.        { USetText(Msg);    };
  249.     virtual void WMNCActivate(RTMessage Msg) = [WM_FIRST + WM_NCACTIVATE]
  250.        { UNCActivate(Msg);    };
  251.     virtual void WMUpdateEntireWindow(RTMessage Msg) = [WM_FIRST + WM_CUSTOMUPDATEWINDOW]
  252.         { UUpdateEntireWindow(Msg); };
  253.     virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE]
  254.         { UClose(Msg);
  255.             TWindow::WMClose(Msg);    };
  256.     virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE]
  257.         {  USize(Msg); };
  258.     virtual void WMDestroy(RTMessage Msg) = [WM_FIRST + WM_DESTROY]
  259.         {    UDestroy(Msg);
  260.             TWindow::WMDestroy(Msg);    };
  261.     virtual void WMEraseBkGnd(RTMessage Msg) = [WM_FIRST + WM_ERASEBKGND]
  262.        {    UEraseBkGnd(Msg);    };
  263.     virtual void WMNCMouseMove(RTMessage Msg) = [WM_FIRST + WM_NCMOUSEMOVE]
  264.        {    UNCMouseMove(Msg);    };
  265.     virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE]
  266.        {    UMouseMove(Msg);    };
  267.     virtual void WMSetCursor(RTMessage Msg) = [WM_FIRST + WM_SETCURSOR]
  268.        {    USetCursor(Msg);    };
  269.     virtual void WMNCLButtonDown(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONDOWN]
  270.         {    UNCLButtonDown(Msg);    };
  271.     virtual void WMNCLButtonUp(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONUP]
  272.         {    UNCLButtonUp(Msg);    };
  273.     virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN]
  274.         {    if(ULButtonDown(Msg))    TWindow::WMLButtonDown(Msg);    };
  275.     virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP]
  276.        {    ULButtonUp(Msg);    };
  277.     virtual void WMNCHitTest(RTMessage Msg) = [WM_FIRST + WM_NCHITTEST]
  278.         {    UNCHitTest(Msg);    };
  279. protected:
  280.     virtual LPSTR GetClassName();
  281.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  282. };
  283. #endif